<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include2923 :: header('导入操作台账（明细表）列表')"/>
</head>
<style>
    .layui-table-cell {
        padding: 0 5px;
        height: auto !important;
        overflow: visible;
        text-overflow: inherit;
        white-space: normal;
        word-break: break-all;
        line-height: 26px !important;
    }

</style>
<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">批次号</label>
                <div class="layui-input-inline">
                    <input type="text" name="batchnum" placeholder="" class="layui-input">
                </div>
                <label class="layui-form-label">概算书类型</label>
                <div class="layui-input-inline">
                    <select name="type" lay-filter="aihao">
                        <option value=""></option>
                        <option value="1">基建类</option>
                        <option value="2">业扩类</option>
                        <option value="3">技改类</option>
                        <option value="4">大修类</option>
                    </select>
                </div>
                <label class="layui-form-label">导入结果</label>
                <div class="layui-input-inline">
                    <select name="status" lay-filter="aihao">
                        <option value=""></option>
                        <option value=0>失败</option>
                        <option value=1>成功</option>
                    </select>
                </div>
                <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit
                        lay-filter="infoImportresultDtl-query">
                    <i class="layui-icon layui-icon-search"></i>
                    查询
                </button>
                <button type="reset" class="pear-btn pear-btn-md">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
        </form>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-body">
        <table id="infoImportresultDtl-table" lay-filter="infoImportresultDtl-table"></table>
    </div>
</div>
</body>

<script type="text/html" id="infoImportresultDtl-toolbar">
    <!--    <button shiro:hasPermission="info:infoImportresultDtl:add" class="pear-btn pear-btn-primary pear-btn-md"-->
    <!--            lay-event="add">-->
    <!--        <i class="layui-icon layui-icon-add-1"></i>-->
    <!--        新增-->
    <!--    </button>-->
    <!--    <button shiro:hasPermission="info:infoImportresultDtl:remove" class="pear-btn pear-btn-danger pear-btn-md"-->
    <!--            lay-event="batchRemove">-->
    <!--        <i class="layui-icon layui-icon-delete"></i>-->
    <!--        删除-->
    <!--    </button>-->
</script>

<script type="text/html" id="infoImportresultDtl-bar">
    <!--    <button shiro:hasPermission="info:infoImportresultDtl:edit" class="pear-btn pear-btn-primary pear-btn-sm"-->
    <!--            lay-event="edit" title="修改"><i class="layui-icon layui-icon-edit"></i>-->
    <!--    </button>-->

    <!--    <button shiro:hasPermission="info:infoImportresultDtl:remove" class="pear-btn pear-btn-danger pear-btn-sm"-->
    <!--            lay-event="remove" title="删除"><i class="layui-icon layui-icon-delete"></i>-->
    <!--    </button>-->
</script>


<script type="text/html" id="infoImportresultDtl-type">
    {{#if (d.dataState == '0') { }}
    <span class="layui-badge layui-bg-orange">开启</span>
    {{# }else if(d.dataState == '-1'){ }}
    <span class="layui-badge layui-bg-blue">关闭</span>
    {{# } }}
</script>

<th:block th:include="include2923 :: footer"/>
<script th:inline="javascript" type="text/javascript">
    layui.use(['table', 'form', 'jquery'], function () {
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;

        var MODULE_PATH = rootPath + "/InfoImportresultDtlController/";
        var cols = [
            [
                // {type: 'checkbox'},
                //
                // {title: '主键ID', field: 'id', align: 'center'},

                // {title: '主表id', field: 'mainid', align: 'center'},

                {title: '导入时间', field: 'createtime', align: 'center', width: 200},

                {title: '文件名称', field: 'filename', align: 'center', width: 350},

                {title: '批次', field: 'batchnum', align: 'center', width: 150},

                // {
                //     title: '所属环节', field: 'step', align: 'center', width: 150,templet: function (res) {
                //         if (res.step == '1') {
                //             return '可研';
                //         } else if (res.step == '2') {
                //             return '初设';
                //         } else if (res.step == '3') {
                //             return '结算';
                //         } else {
                //             return '';
                //         }
                //     }
                // },

                {
                    title: '工程类别', field: 'type', align: 'center', width: 150, templet: function (res) {
                        if (res.type == '1') {
                            return '基建类';
                        } else if (res.type == '2') {
                            return '业扩类';
                        } else if (res.type == '3') {
                            return '技改类';
                        } else if (res.type == '4') {
                            return '大修类';
                        } else {
                            return '';
                        }
                    }
                },

                // {title: '后缀名称', field: 'suffix', align: 'center'},

                {
                    title: '导入结果', field: 'status', align: 'center', width: 150, templet: function (res) {
                        if (res.status == '0') {
                            return '<div style="background-color:#ff7777; width: 100%; height: 100%;"><a class=""style="color:#fff">失败</a></div>';
                        } else {
                            return '成功';
                        }
                    }
                },

                {title: '失败原因', field: 'reason', align: 'center', width: 400},
                //
                // {title: '操作', toolbar: '#infoImportresultDtl-bar', align: 'center'}
            ]
        ]

        //table表单列表
        table.render({
            elem: '#infoImportresultDtl-table',
            url: MODULE_PATH + 'finddtl?step=3',
            page: true,
            method: 'get',
            cols: cols,
            skin: 'line',
            toolbar: '#infoImportresultDtl-toolbar',
            defaultToolbar: [{
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }],
            height:500,
            limit:80,
            cellMinHeight: 80, // 设置最小高度
            // initSort: {
            //     field: 'createtime', // 按 id 字段排序
            //     type: 'desc' // 降序排序
            // },
            // where: {'step': 1}
        });

        //table图标事件绑定
        table.on('tool(infoImportresultDtl-table)', function (obj) {
            if (obj.event === 'remove') {
                window.remove(obj);
            } else if (obj.event === 'edit') {
                window.edit(obj);
            }
        });

        //table工具栏绑定
        table.on('toolbar(infoImportresultDtl-table)', function (obj) {
            if (obj.event === 'add') {
                window.add();
            } else if (obj.event === 'refresh') {
                window.refresh();
            } else if (obj.event === 'batchRemove') {
                window.batchRemove(obj);
            }
        });

        //查询按钮绑定
        form.on('submit(infoImportresultDtl-query)', function (data) {
            table.reload('infoImportresultDtl-table', {where: data.field})
            return false;
        });


        //添加
        window.add = function () {
            layer.open({
                type: 2,
                title: '新增',
                shade: 0.1,
                area: ['500px', '500px'],
                content: MODULE_PATH + 'add'
            });
        }
        //修改
        window.edit = function (obj) {
            layer.open({
                type: 2,
                title: '修改',
                shade: 0.1,
                area: ['500px', '500px'],
                content: MODULE_PATH + 'edit/' + obj.data['id']
            });
        }
        //删除
        window.remove = function (obj) {
            layer.confirm('确定要删除该数据', {icon: 3, title: '提示'}, function (index) {
                layer.close(index);
                var loading = layer.load();
                $.ajax({
                    url: MODULE_PATH + "remove?ids=" + obj.data['id'],
                    dataType: 'json',
                    type: 'delete',
                    success: function (result) {
                        layer.close(loading);
                        if (result.code == 200) {
                            layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                                obj.del();
                            });
                        } else {
                            layer.msg(result.msg, {icon: 2, time: 1000});
                        }
                    }
                })
            });
        }

        //批量删除
        window.batchRemove = function (obj) {
            var data = table.checkStatus(obj.config.id).data;
            if (data.length === 0) {
                layer.msg("未选中数据", {icon: 3, time: 1000});
                return false;
            }
            var ids = "";
            for (var i = 0; i < data.length; i++) {
                ids += data[i].id + ",";
            }
            ids = ids.substr(0, ids.length - 1);
            layer.confirm('确定要删除这些数据', {icon: 3, title: '提示'}, function (index) {
                layer.close(index);
                var loading = layer.load();
                $.ajax({
                    url: MODULE_PATH + "remove?ids=" + ids,
                    dataType: 'json',
                    type: 'delete',
                    success: function (result) {
                        layer.close(loading);
                        if (result.code == 200) {
                            layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                                table.reload('infoImportresultDtl-table');
                            });
                        } else {
                            layer.msg(result.msg, {icon: 2, time: 1000});
                        }
                    }
                })
            });
        }
        //刷新按钮
        window.refresh = function () {
            table.reload('infoImportresultDtl-table');
        }
    })
</script>
</html>